home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 18
/
CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso
/
CUCD
/
Magazine
/
WiredWorld
/
THOR_2.5_upgrade
/
rexx
/
Others
/
BrowseTHOR.dopus5
next >
Wrap
Text File
|
1997-09-15
|
21KB
|
948 lines
/* BrowseTHOR.dopus5 by Troels Walsted Hansen <troelsh@powertech.no>
** $VER: BrowseTHOR.dopus5 1.7 (8.8.95)
**
** This script allows you to browse a filedatabase in THOR from
** Dopus5. You may list systems, dirs and files in a Dopus5 lister
** and perform various functions. Delete works on both files and dirs,
** download works on files.
** The script is controlled through a message port which it opens.
** It is recommended that you use the Dopus5 button bank which is
** supplied along with the script.
**
** Thanks to Matthias Bartosik for the idea for this script. :-)
**
** History:
** ¯¯¯¯¯¯¯¯
** BrowseTHOR.dopus5 v1.0 (27.05.95)
** · first released version
**
** BrowseTHOR.dopus5 v1.1 (27.05.95)
** · implemented delete of dirs and files
**
** BrowseTHOR.dopus5 v1.5 (13.06.95)
** · fixed ugly resize at startup
** · implemented customhandler which means that the script will now handle
** doubleclicks, parent clicks and quitting when the Lister is closed!
** · all refreshes are now 'full' which means that the titlebar and the
** statusbar are updated, not just the Lister contents
**
** BrowseTHOR.dopus5 v1.6 (15.06.95)
** · you get a button for quitting old if you start a new BrowseTHOR
** · busypointer and progressbar on delete and download
** · status window saying 'Reading system/directory', just like Dopus
** · maintenance on one or more systems implemented
** · search implemented. Search for a keyword or an exact hit across
** multiple systems in all dirs. Search in selected dirs within one
** system not implemented yet.
**
** BrowseTHOR.dopus5 v1.7 (08.08.95)
** · implemented true 'parent' and 'root' (new in Dopus 5.11)
** · changed the BrowseTHOR button bar to use XHelvetica size 13 because I
** bought a nice CyberVision64 graphicscard and increased my resolution :)
** · changed the BrowseTHOR button bar to point to Dopus5:ARexx/BrowseTHOR.dopus5
** because it is more logical than THOR:Rexx/BrowseTHOR.dopus5.
** · implemented the 'path' event. This means you can enter a valid
** systemname:dirname in the lister path gadget, and the system/dir will
** be read.
** · ditched my ugly makestem() function in favor of Dopus 5.11's stem argument
** (a bit less ugly, but not much).
*/
/* Customize these first variables yourself */
pos = '241/16/652/373' /* Windowspecs: leftedge/topedge/width/height */
showfilenumber = 'yes' /* Whether or not to show the number of files in
the directory as the size of the directory.
Setting this to 'no' will improve dirlisting
speed. */
/* the rest is off limits */
options results
options failat 31
/* needs Dopus 5, bbsread.library and rexxsupport.library functions */
p = address() || ' ' || show('P',,)
dopusport = pos('DOPUS.',p)
if dopusport > 0 then dopusport = word(substr(p,dopusport),1)
else
do
say 'No Dopus port found!'
exit 10
end
if ~show('p', 'BBSREAD') then
do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
if(rc ~= 0) then
do
address(dopusport)
dopus request '"Unable to access bbsread.library, exiting."' '_Ok'
exit
end
end
if ~show('L', 'rexxsupport.library') then
do
if ~addlib('rexxsupport.library', 0, -30, 0) then
do
address(dopusport)
dopus request '"ARexx support library not available, exiting."' '"_Ok"'
exit
end
end
/* multiple BrowseTHORs will have to wait.... */
if(pos('BrowseTHOR', show('P',,)) ~= 0) then
do
address(dopusport)
dopus request '"Only one BrowseTHOR at the time, please."' '_Ok|_Quit other'
if(rc = 0) then
do
address('BrowseTHOR')
QUIT
end
exit
end
/* open our very own message port */
port = openport('BrowseTHOR')
/* open new lister */
address(dopusport)
lister new pos
handle = result
/* show list of systems first */
call showsystems()
/* tell Dopus we want notifications about events concerning our Lister */
lister set handle handler 'BrowseTHOR'
if(rc ~= 0) then exit 10
/* wait for commands */
do until status = 'CLOSE'
call waitpkt('BrowseTHOR')
packet = getpkt('BrowseTHOR')
if packet ~= null() then
do
cmd = getarg(packet, 0)
/*
trace results
say cmd
trace off
*/
if(cmd = 'doubleclick' | cmd = 'drop' | cmd = 'dropfrom' | cmd = 'path') then
do
Arg1 = getarg(Packet, 1) /* handle */
Arg2 = getarg(Packet, 2) /* entry */
end
interpret 'call ' || cmd || '()'
call reply(packet, 0)
/* it seems Dopus has a habit of forgetting the custom handler?! */
lister set handle handler 'BrowseTHOR'
if(rc ~= 0) then exit 10
end
end
call closeport(port)
/* we're done for now, close Lister and exit */
lister close handle
exit
/********************************************************************************/
/*** function for handling 'drop' event */
drop:
address(dopusport)
dopus request '"' || 'What use do I have for ' || Arg2 || '?' || '"' '_Upload it!'
return
/*** function for handling 'dropfrom' event */
dropfrom:
address(dopusport)
dopus request '"' || 'What would you like me to do with ' || Arg2 || '?' || '"' '_Download it!'
return
/*** function for handling 'doubleclick' event */
doubleclick:
select
when(system = '' & dir = '') then
do
system = Arg2
call showdirs()
end
when(system ~= '' & dir = '') then
do
dir = Arg2
call showfiles()
end
when(system ~= '' & dir ~= '') then
do
address(dopusport)
dopus request '"' || 'This ought to show detailed info about the file: ' || Arg2 || '"' '_Yeah!'
end
otherwise nop
end
return
/*** function for handling 'path' event */
path:
/* parse the entered data */
posi = pos(':', Arg2)-1
if(posi = '-1' | Arg2 = '') then
do
call showsystems()
return
end
else system = left(Arg2, posi)
dir = substr(Arg2, posi+2)
if(dir = '') then
do
call showdirs()
return
end
call showfiles()
return
/*** function for handling 'active' event */
active:
/* do I have any use for this event? (will I ever receive it?) */
address(dopusport)
dopus request '"' || 'How did you accomplish this?' || '"' '_You tell me!!'
return
/*** function for handling 'inactive' event */
inactive:
/* test if the Lister was closed */
lister query handle visible
if(rc > 9) then
do
call Quit()
return
end
system = ''
dir = ''
return
/*** function for handling 'parent' event */
parent:
select
when(system ~= '' & dir = '') then
do
system = ''
call showsystems()
end
when(system ~= '' & dir ~= '') then
do
dir = ''
call showdirs()
end
otherwise nop
end
return
/*** function for handling 'root' event */
root:
call showsystems()
return
/*** function for listing all systems */
showsystems:
system = ''
dir = ''
address(dopusport)
lister clear handle
lister set handle display name
lister set handle title 'Select a system:'
lister set handle path ''
address(bbsread)
GETBBSLIST stem BBSLIST
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
address(dopusport)
lister set handle busy on
do i=1 to BBSLIST.COUNT
lister add handle '"'BBSLIST.i'"' '0' '-1' '0' '-'
if(rc ~= 0) then
do
dopus request '"Something went wrong while adding systems to lister."' '_Ok'
return
end
end
address(dopusport)
lister refresh handle full
lister set handle busy off
return
/*** function for listing all dirs in a system */
showdirs:
dir = ''
if(system = '') then
do
/* get the (first) selected system name */
address(dopusport)
lister query handle numselfiles
if(result ~= 1) then
do
dopus request '"Please adjust number of selected systems to ONE."' '_Ok'
return
end
lister query handle selfiles
system = strip(result, B, '"')
end
address(bbsread)
GETFAREALIST bbsname '"'system'"' stem FAREALIST
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
address(dopusport)
if(FAREALIST.COUNT = 0) then
do
dopus request '"This system has no filedatabase."' '_Ok'
lister select handle '"'system'"' off
lister refresh handle full
system = ''
dir = ''
return
end
lister clear handle
lister set handle display name size
lister set handle title 'Select a dir:'
lister set handle path system || ':'
lister set handle busy on
lister set handle progress '-1' 'Reading system...'
do i=1 to FAREALIST.COUNT
address(dopusport)
lister query handle abort
if(result) then break
if(showfilenumber = 'yes') then
do
address(bbsread)
GETFAREADATA bbsname '"'system'"' fareaname '"'FAREALIST.i'"' stem FAREADATA
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
end
if(FAREADATA.NUMFILES = 0) then dirsize = 0
else dirsize = FAREADATA.NUMFILES
end
else dirsize = '0'
address(dopusport)
lister add handle '"'FAREALIST.i'"' dirsize '1' '0' '-'
if(rc ~= 0) then
do
dopus request '"Something went wrong while adding dirs to lister."' '_Ok'
break
end
end
address(dopusport)
lister refresh handle full
lister set handle busy off
return
/*** function for listing all files in a dir */
showfiles:
if(dir = '') then
do
/* get the (first) selected dirname */
address(dopusport)
lister query handle numseldirs
if(result ~= 1) then
do
dopus request '"Please adjust number of selected dirs to ONE."' '_Ok'
return
end
lister query handle seldirs
dir = strip(result, B, '"')
end
/* needs the number of the first file in the file area */
address(bbsread)
GETFAREADATA bbsname '"'system'"' fareaname '"'dir'"' stem FAREADATA
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
address(dopusport)
if(FAREADATA.NUMFILES = 0) then
do
dopus request '"This directory is empty."' '_Ok'
lister select handle '"'dir'"' off
lister refresh handle full
dir = ''
return
end
lister clear handle
lister set handle display name size date comment
lister set handle title 'Select files:'
lister set handle path system || ':' || dir
lister set handle busy on
lister set handle progress '-1' 'Reading directory...'
filenr = FAREADATA.FIRSTFILE
do until(filenr = 0)
address(dopusport)
lister query handle abort
if(result) then break
drop FILE. /* Important */
address(bbsread)
READBRFILE bbsname '"'system'"' fareaname '"'dir'"' filenr tagsstem FILE
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
filenr = result
if(FILE.NAME ~= 'FILE.NAME') then
do
address(dopusport)
lister add handle FILE.NAME FILE.SIZE '-1' FILE.DATE 'rwed' FILE.DESCRIPTION.1
if(rc ~= 0) then
do
dopus request '"Something went wrong while adding files."' '_Ok'
break
end
end
end
address(dopusport)
lister refresh handle full
lister set handle busy off
return
/*** function for downloading selected files */
download:
/* get the selected filesnames */
address(dopusport)
lister query handle numselfiles
if(result = 0) then
do
dopus request '"Please select at least one file."' '_Ok'
return
end
drop files.
lister query handle selfiles stem files.
lister set handle busy on
lister set handle progress files.count 'Making download events...'
EVENT.DIRECTORY = dir
do i=0 to files.count-1
EVENT.FILENAME = files.i
/* update the progress bar */
address(dopusport)
lister set handle progress count i+1
lister set handle progress name EVENT.FILENAME
lister query handle abort
if(result) then break
/* write the download event */
address(bbsread)
WRITEBREVENT bbsname '"'system'"' event 4 stem EVENT
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
address(dopusport)
lister select handle '"'EVENT.FILENAME'"' off
end
lister refresh handle full
lister set handle busy off
return
/*** function for deleting selected dirs/files */
delete:
address(dopusport)
/* check if called from systemlist */
if(system = '' & dir = '') then
do
dopus request '"You cannot delete whole filedatabases, sorry."' '_Ok'
return
end
/* dirs or files? */
lister query handle numseldirs
mynumseldirs = result
lister query handle numselfiles
mynumselfiles = result
select
when(mynumseldirs ~= 0) then
do
/* get the selected dirnames */
drop dirs.
lister query handle seldirs stem dirs.
txt = 'Are you sure you want to delete ' || mynumseldirs || ' dir(s)?'
dopus request '"'txt'"' '_Yes|_Abort'
if(rc = 0) then return
lister set handle busy on
lister set handle progress dirs.count 'Deleting dirs...'
do i=0 to dirs.count-1
/* update the progress bar */
address(dopusport)
lister set handle progress count i+1
lister set handle progress name dirs.i
lister query handle abort
if(result) then break
/* mark the dir(s) as deleted */
address(bbsread)
CONFIGFAREA bbsname '"'system'"' fareaname '"'dirs.i'"' deletefarea
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
address(dopusport)
lister remove handle '"'dirs.i'"'
end
lister refresh handle full
lister set handle busy off
end
when(mynumselfiles ~= 0) then
do
/* get the selected filenames */
drop files.
lister query handle selfiles stem files.
txt = 'Are you sure you want to delete ' || mynumselfiles || ' file(s)?'
dopus request '"'txt'"' '_Yes|_Abort'
if(rc = 0) then return
lister set handle busy on
lister set handle progress files.count 'Deleting files...'
do i=0 to files.count-1
FILE.NAME = files.i
/* update the progress bar */
address(dopusport)
lister set handle progress count i+1
lister set handle progress name FILE.NAME
lister query handle abort
if(result) then break
/* get the number of the file */
address(bbsread)
SEARCHBRFILE bbsname '"'system'"' stem SRESULT fareaname '"'dir'"' search '"'FILE.NAME'"' NAME
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
if(SRESULT.FILEAREA.COUNT = 0) then iterate
/* mark file as deleted */
address(bbsread)
WRITEBRFILE bbsname '"'system'"' fareaname '"'dir'"' stem FILE updatefilenr '"'SRESULT.FILE.1.1'"' deletefile
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
address(dopusport)
lister remove handle '"'FILE.NAME'"'
end
lister refresh handle full
lister set handle busy off
end
otherwise
do
dopus request '"Please select at least one directory or file."' '_Ok'
return
end
end
return
/*** function for performing maintenance on the selected system(s) */
maintenance:
address(dopusport)
if(system ~= '') then
do
dopus request '"Maintenance should be performed from the systems list."' '_Ok|_Show systems'
if(rc = 0) then call showsystems()
return
end
/* get the selected systemnames */
lister query handle numselfiles
if(result = 0) then
do
dopus request '"Please select at least one system."' '_Ok'
return
end
dopus request '"' 'Are you sure you want to clean up at ' || result || ' system(s)?' || '"' '_Proceed|_Abort'
if(rc = 0) then return
drop files.
lister query handle selfiles stem files.
lister set handle busy on
lister set handle progress files.count 'Cleaning up...'
do i=0 to files.count-1
/* update the progress bar */
address(dopusport)
lister set handle progress count i+1
lister set handle progress name files.i
lister query handle abort
if(result) then break
/* pack the filedatabase */
address(bbsread)
PACKDATAFILE bbsname '"'files.i'"' FILEDATA
if(rc ~= 0) then
do
address(dopusport)
lister set handle busy off
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
address(dopusport)
lister select handle '"'files.i'"' off
end
address(dopusport)
lister refresh handle full
lister set handle busy off
return
/*** function for searching for files */
search:
address(dopusport)
select
when(system = '' & dir = '') then nop
when(system ~= '' & dir = '') then
do
dopus request '"Search for pattern in selected dirs...NOT IMPLEMENTED YET."' '_Darn'
return
end
when(system ~= '' & dir ~= '') then
do
dopus request '"You can''t search inside files, silly."' '_Okay'
return
end
otherwise return
end
if(pattern = 'PATTERN') then pattern = 'THOR'
dopus getstring '"Enter search pattern..."' '50' '"'pattern'"' '_Keyword|_Exact|_Cancel'
if(result = '' | dopusrc = 0) then return
pattern = result
if(dopusrc = 2) then str = 'NAME'
else str = 'KEYWORD'
/* get the selected systemnames */
lister query handle numselfiles
if(result = 0) then
do
dopus request '"Please select at least one system."' '_Ok'
return
end
drop files.
lister query handle selfiles stem files.
lister set handle busy on
do i=0 to files.count-1
/* update the status window */
address(dopusport)
lister set handle progress '-1' 'Searching for pattern at ' || files.i || '...'
lister query handle abort
if(result) then break
/* do the searching */
call searchsystem()
/* open requester which will allow the user to proceed to searching the next system */
if(i ~= files.count-1) then
do
address(dopusport)
dopus request '"Press next to proceed to next system..."' '_Next|_Abort'
if(rc = 0) then leave i /* +/- 1 ???? */
end
end
address(dopusport)
lister set handle busy off
return
/*** function for searching for a pattern at one specific system */
searchsystem:
address(bbsread)
SEARCHBRFILE bbsname '"'files.i'"' stem SRESULT search '"'pattern'"' str
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
if(result > 0) then
do
address(dopusport)
lister clear handle
lister set handle display name size date comment
lister set handle title 'Select files:'
lister set handle path files.i || ':' || 'Found_in_search'
system = files.i
do f=1 to SRESULT.FILEAREA.COUNT
/* check the status window abort button */
address(dopusport)
lister query handle abort
if(result) then break
do j=1 to SRESULT.FILE.f.COUNT
drop FILE. /* Important */
address(bbsread)
say bbsname '"'files.i'"' fareaname '"'SRESULT.FILEAREA.f'"' filenr SRESULT.FILE.f.j tagsstem FILE datastem DATA
READBRFILE bbsname '"'files.i'"' fareaname '"'SRESULT.FILEAREA.f'"' filenr SRESULT.FILE.f.j tagsstem FILE datastem DATA
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
return
end
if(bitand(DATA.FLAGS, '00000001'x) ~= '00000001'x) then
do
address(dopusport)
lister add handle FILE.NAME FILE.SIZE '-1' FILE.DATE 'rwed' FILE.DESCRIPTION.1
if(rc ~= 0) then
do
dopus request '"Something went wrong while adding files."' '_Ok'
break
end
end
end
end
end
else
do
address(dopusport)
dopus request '"No files found."' '_Ok'
return
end
address(dopusport)
lister refresh handle full
return
/*** function for searching for a msg in a FileInfo conference and displaying it with Dopus' reader */
showfileinfo:
/* get the selected filesnames */
address(dopusport)
dopus request '"Waiting for Leo to finish SEARCHBRMESSAGE..."' '_Ok'
return
lister query handle numselfiles
if(result = 0) then
do
dopus request '"Please select at least one file."' '_Ok'
return
end
drop files.
lister query handle selfiles stem files.
lister set handle busy on
lister set handle progress files.count 'Searching for FileInfo...'
EVENT.DIRECTORY = dir
do i=0 to files.count-1
EVENT.FILENAME = files.i
/* update the progress bar */
address(dopusport)
lister set handle progress count i+1
lister set handle progress name EVENT.FILENAME
lister query handle abort
if(result) then break
/* write the download event */
address(bbsread)
WRITEBREVENT bbsname '"'system'"' event 4 stem EVENT
if(rc ~= 0) then
do
address(dopusport)
dopus request '"'BBSREAD.LASTERROR'"' '_Ok'
iterate
end
address(dopusport)
lister select handle '"'EVENT.FILENAME'"' off
end
lister refresh handle full
lister set handle busy off
return
/*** function for ending script */
quit:
status = 'CLOSE'
return